﻿package org.atk {
	import flash.text.TextField;
	import flash.text.TextFormat;
	import org.aswing.ASColor;
	import org.aswing.AssetIcon;
	import org.atk.icons.MyIcons;
	import org.atk.components.treegridview.TreeGridViewItem;
	import org.aswing.geom.IntRectangle;
	import flash.display.Sprite;
	import org.atk.components.treegridview.TreeGridViewRenderer;
	import org.flashdevelop.utils.FlashConnect;
	
	/**
	 * ...
	 * @author AeTky
	 */
	public class MyRenderer extends TreeGridViewRenderer{
		
		public function MyRenderer() {
			
		}
		override public function renderCellContent(sprite:Sprite, bounds:IntRectangle, columnIdx:int, item:TreeGridViewItem):void {
			
			var icn:AssetIcon = null;
			var v:*= item.Data.getValue(columnIdx);
			if (v == null) return;
			
			if (columnIdx == 1)
				icn = MyIcons.getIcon("phone");
			if (columnIdx == 2)
				icn = MyIcons.getIcon("mail");
				
			var xPatch:int = 0;
			if (icn != null) xPatch = 2 + icn.getAsset().width;
			//super.renderCellContent(sprite, bounds, columnIdx, item);
			
			drawIcon(sprite, bounds, icn);
			bounds.x = bounds.x +xPatch;
			bounds.width = bounds.width - xPatch;
			
			var lb:TextField=textOut(sprite, bounds, item.Data.getValue(columnIdx));
			
			if (columnIdx != 0) return;
			var tf:TextFormat = lb.getTextFormat();
			tf.bold = true;
			tf.color = ASColor.BLUE.getRGB();
			lb.setTextFormat(tf);
			
		}
	}
	
}